<?php
include_once("../modules/checkA.php");
include_once("../../config.php"); 
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'equipment'");
?>


<?
//用来判断当前系统属于什么板块
$system_part = $plate['mid'];
include_once("detail-function.php"); 
?>



<?


if(!$_REQUEST ['applydate'])
{
    $_REQUEST ['applydate']=date("Y-m");
}
$applydate  = addslashes($_REQUEST ['applydate']);

?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include_once(ROOT_PATH_.'/controlbase/modules/head.php'); ?>
</head>

<body>

<div id="topbar"><?php include ROOT_PATH_.'/controlbase/modules/topbar.php'; ?></div>

<div id="container" class="<? echo $system_part ?>">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_.'/controlbase/modules/sidebar.php'; ?>
        </div>


<div id="content" >
<h1> 车辆统计 </h1>



<!--<a href="--><?// echo $domain ?><!--/controlbase/maintain/detail-add.php?nav-itemed=equipment&type=季审&equipmentid=--><?//echo $detail['nid']?><!--"  class="layui-btn">季审</a>-->
<!--<a href="--><?// echo $domain ?><!--/controlbase/maintain/detail-add.php?nav-itemed=equipment&type=年审&equipmentid=--><?//echo $detail['nid']?><!--"  class="layui-btn">年审</a>-->
<!--<a href="--><?// echo $domain ?><!--/controlbase/maintain/detail-add.php?nav-itemed=equipment&type=强保&equipmentid=--><?//echo $detail['nid']?><!--"  class="layui-btn">强保</a>-->
<!--<a href="--><?// echo $domain ?><!--/controlbase/maintain/detail-add.php?nav-itemed=equipment&type=全保&equipmentid=--><?//echo $detail['nid']?><!--"  class="layui-btn">全保</a>-->






<div class="detail-box equipment-detail-static-box layui-form statistics-box">

<div class="detail-boxes">
<ul class="detail-boxing">


<div class="content">

    <?
    $rental=select_one_line_all_items($table_Prefix."rental","status = '借出' and equipmentid = '".$detail['equipmentid']."' order by borrowdate desc");

    $employee=select_one_line_all_items($table_Prefix."employee","nid = '".$rental['borrower']."'");

    ?>

<ul>
    <li>车牌:<? echo $detail['name']?></li>
<!--    <li>持有人:--><?// echo $employee['name']?><!--</li>-->
<!--    <li>购买日期:--><?// echo $detail['buydate']?><!--</li>-->

<!--    <li>季审:--><?// echo $detail['jishen']?><!--(--><?//echo count_days(date('Y-m-d'),$detail[$i]['jishen'])?><!--天)</li>-->
<!--    <li>年审:--><?// echo $detail['nianshen']?><!--(--><?//echo count_days(date('Y-m-d'),$detail[$i]['nianshen'])?><!--天)</li>-->
<!--    <li>年审周期:--><?// echo $detail['period']?><!--</li>-->
<!---->
<!--    <li>强保时间:--><?// echo $detail['qiangbao']?><!--(--><?//echo count_days(date('Y-m-d'),$detail[$i]['qiangbao'])?><!--天)</li>-->
<!--    <li>全保时间:--><?// echo $detail['quanbao']?><!--(--><?//echo count_days(date('Y-m-d'),$detail[$i]['quanbao'])?><!--天)</li>-->

    <li>牌子:<? echo $detail['brand']?></li>

    <?
    $department=select_one_line_all_items($table_Prefix."department","nid = '".$detail['departmentid']."'");
    ?>


    <li>所属部门:<? echo $department['name']?></li>


    <li>状态:<? echo $detail['status']?></li>

    <li>备注:<? echo $detail['remark']?></li>

</ul>
</div>

















    <div class="select-box layui-form">
        <form action="detail-statistic.php?nav-itemed=equipment&nid=<?echo $detail['nid']?>" >





            <div class="layui-form-item">
                <label class="layui-form-label">时间段</label>

                <div class="layui-input-block">
                    <input type="text" name="select_startday" placeholder="请输入开始时间" autocomplete="off" class="layui-input"  onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" style="float: left; width: 112px" value="<?if($_REQUEST['select_startday']){echo $_REQUEST['select_startday'] ;} ?>" >

                    <span style="float: left;margin: 0 4px; line-height: 30px;">-</span>


                    <input type="text" name="select_endday" placeholder="请输入结束时间" autocomplete="off" class="layui-input" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  style="float: left; width:112px" value="<?if($_REQUEST['select_endday']){echo $_REQUEST['select_endday'] ;} ?>"  >

                    <input type="hidden" name="nav-itemed" value="equipment"/>
                    <input type="hidden" name="nid" value="<?echo $detail['nid']?>"/>



                </div>
                </div>




                <div class="layui-form-item">
                    <button class="layui-btn" style="float: left;margin: 0 4px; line-height: 30px;    height: 38px;
    line-height: 38px;">查找</button>


                </div>











            <br class="clearfloat"/>
        </form>

    </div>






    <?



    if($_REQUEST['select_startday'])
    {
        $start_date=$_REQUEST['select_startday']." 00:00:00";
        $start_date_str=" and applydate > '".$start_date."'";
        $repair_start_date_str=" and repairdate > '".$start_date."'";
        $rental_start_date_str=" and borrowdate > '".$start_date."'";
        $ticket_start_date_str=" and ticketdate > '".$start_date."'";
        $access_start_date_str=" and accessdate > '".$start_date."'";
    }
    else
    {
        $start_date_str="";
    }




    if($_REQUEST['select_endday'])
    {
        $end_date=$_REQUEST['select_endday']." 23:59:59";
        $end_date_str=" and applydate < '".$end_date."'";
        $repair_end_date_str=" and repairdate < '".$start_date."'";
        $rental_end_date_str=" and borrowdate < '".$start_date."'";
        $ticket_end_date_str=" and ticketdate < '".$start_date."'";
        $access_end_date_str=" and accessdate < '".$start_date."'";
    }
    else
    {
        $end_date_str="";
    }


    $select_str=$start_date_str.$end_date_str;

    ?>









        <table class="layui-table">
            <colgroup>
                <col width="80">
                <col width="200">
                <col >
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>序号</th>
                <th>项目</th>
                <th>统计</th>
                <th>金额</th>
            </tr>
            </thead>
            <tbody>
<!--            <tr>-->
<!--                <td>1</td>-->
<!--                <td>维修次数</td>-->
<!--                <td>--><?//echo count_by_item($table_Prefix."repair","equipmentid='".$trans_nid."'".$repair_start_date_str.$repair_end_date_str)?><!--</td>-->
<!--                <td>--><?//echo sum_total($table_Prefix."repair","cost","equipmentid='".$trans_nid."'".$repair_start_date_str.$repair_end_date_str)?><!--</td>-->
<!--            </tr>-->
<!--            <tr>-->
<!--                <td>2</td>-->
<!--                <td>罚单次数</td>-->
<!--                <td>--><?//echo count_by_item($table_Prefix."ticket","equipmentid='".$trans_nid."'".$ticket_start_date_str.$ticket_end_date_str)?><!--</td>-->
<!--                <td>--><?//echo sum_total($table_Prefix."ticket","cost","equipmentid='".$trans_nid."'".$ticket_start_date_str.$ticket_end_date_str)?><!--</td>-->
<!--            </tr>-->
<!--            <tr>-->
<!--                <td>3</td>-->
<!--                <td>未处理记分</td>-->
<!--                <td>--><?//echo sum_total($table_Prefix."ticket","mark","equipmentid='".$trans_nid."'".$ticket_start_date_str.$ticket_end_date_str)?><!--</td>-->
<!--                <td>/</td>-->
<!--            </tr>-->
<!--            <tr>-->
<!--                <td>4</td>-->
<!--                <td>领用次数</td>-->
<!--               <td>--><?//echo count_by_item($table_Prefix."rental","equipmentid='".$trans_nid."'".$rental_start_date_str.$rental_end_date_str)?><!--</td>-->
<!--                <td>/</td>-->
<!--            </tr>-->
<!--            <tr>-->
<!--                <td>5</td>-->
<!--                <td>累积加油</td>-->
<!--                <td>--><?//echo count_by_item($table_Prefix."refueling","equipmentid='".$trans_nid."'".$select_str)?><!--</td>-->
<!--                <td>--><?//echo sum_total($table_Prefix."refueling","cost","equipmentid='".$trans_nid."'".$select_str)?><!--</td>-->
<!--            </tr>-->
<!---->
<!--            <tr>-->
<!--                <td>6</td>-->
<!--                <td>考试通过人数</td>-->
<!--                <td>--><?//echo count_by_item($table_Prefix."exam","equipmentid='".$trans_nid."' and status = '通过' ".$select_str)?><!--</td>-->
<!--                <td>/</td>-->
<!--            </tr>-->
<!---->
<!---->
<!--            <tr>-->
<!--                <td>7</td>-->
<!--                <td>考试未通过</td>-->
<!--                <td>--><?//echo count_by_item($table_Prefix."exam","equipmentid='".$trans_nid."' and status = '不通过' ".$select_str)?><!--</td>-->
<!--                <td>/</td>-->
<!--            </tr>-->
<!---->

            <tr>
                <td>1</td>
                <td>出入记录</td>
                <td><?echo count_by_item($table_Prefix."access_record","equipmentid='".$trans_nid."'".$access_start_date_str.$access_end_date_str)?></td>
                <td><?echo sum_total($table_Prefix."access_record","payment","equipmentid='".$trans_nid."'".$access_start_date_str.$access_end_date_str)?></td>

            </tbody>
        </table>
    </div>






<style>
    .detail-statics-box{ margin-top: 25px;}
    .detail-statics-box h2{ font-size: 30px;}
</style>

<h2>记录信息</h2>
<div class="detail-statics-box">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this"> 出入记录 </li>

        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show "><? include("detail-access-record.php")?></div>
        </div>
</div>












</ul>
</div>
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>


<?php include_once('../modules/footer.php'); ?> </body>
</html>
